//@author A0101728M
#include "CmdSort.h"

const string CmdSort::ASCENDING = "asc";
const string CmdSort::DESCENDING = "desc";
const string CmdSort::DATE_START = "date start";
const string CmdSort::DATE_END = "date end";
const string CmdSort::DATE = "date";
const string CmdSort::NAME = "name";
const string CmdSort::NAME_LENGTH = "name length";
const string CmdSort::DONE = "done";
const string CmdSort::UNDONE = "undone";
const string CmdSort::DUE = "due";
const string CmdSort::OVERDUE = "overdue";

string sort_types[] = {
	CmdSort::DATE_START,
	CmdSort::DATE_END,
	CmdSort::DATE,
	CmdSort::NAME,
	CmdSort::NAME_LENGTH,
	CmdSort::DONE,
	CmdSort::UNDONE,
	CmdSort::DUE,
	CmdSort::OVERDUE
};

const vector<string> CmdSort::SORT_TYPES(sort_types, sort_types+9);


CmdSort::CmdSort(cmdTypes cmdType, vector<string> params, string origStr) :
	Cmd(cmdType, params, origStr) {
		vector<Date> datesFound;
		vector<string> notDates;
		if (Parser::findDates(params, &datesFound, &notDates) == 2){
			keywords.push_back(datesFound[0].toString());
			keywords.push_back(datesFound[1].toString());
		}
		else {
			keywords = params;
		}
}

CmdSort::~CmdSort(void)
{
}

vector<string> CmdSort::getKeywordVector(){
	return keywords;
}